<template>
	<view class="pad15">
		<u-form :model="form" ref="uForm" label-position="top">
			<u-form-item label="公司名称"><u-input v-model="form.name" placeholder="请输入公司名称"/></u-form-item>
			<u-form-item label="法人姓名"><u-input v-model="form.contacts" placeholder="请输入法人姓名"/></u-form-item>
			<u-form-item label="法人联系方式"><u-input v-model="form.mobile" placeholder="请输入法人联系方式"/></u-form-item>
			<u-form-item label="上传身份证正反面">
				<view class="flex row-between">
						<view class="text-center" @click="IdCardZ">
							<image :src="showIdCardZ" class="h226 w330 mr30"></image>
							<text>正面</text>
						</view>
						<view class="text-center" @click="IdCardF">
							<image :src="showIdCardF" class="h226 w330 mr30"></image>
							<text>反面</text>
						</view>
				</view>
			</u-form-item>
			<u-form-item label="上传营业执照" :border-bottom='false'>
				<view class="flex row-between">
					<image :src="showbusiness" class="h202 w202" @click="business"></image>
				</view>
			</u-form-item>
		</u-form>
		
		<!-- 底部的确认按钮 -->
		<view class="footerbtn h88" @click="submit">
			立即申请
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				showIdCardZ:'../../static/image/index/idcard.png',
				showIdCardF:'../../static/image/index/idcard.png',
				showbusiness:'../../static/image/index/upload2.png',
				form:{
					//公司名称
					name:'',
					//法人名称
					contacts:'',
					//手机号
					mobile:'',
					//身份证正面
					idcard_front:'',
					//	身份证反面
					idcard_back:'',
					//营业执照
					business_license:'',
					//地址
					// address:''
				}
			};
		},
		methods:{
			//上传id正面
			IdCardZ() {
				this.$tool.upload().then(res=>{
					console.log(res)
					this.form.idcard_front=res.id
					this.showIdCardZ=res.showImg
				})
			},
			//上传id反面
			IdCardF() {
				this.$tool.upload().then(res=>{
					console.log(res)
					this.form.idcard_back=res.id
					this.showIdCardF=res.showImg
				})
			},
			//上传营业执照
			business() {
				this.$tool.upload().then(res=>{
					console.log(res)
					this.form.business_license=res.id
					this.showbusiness=res.showImg
				})
			},
			//提交
			submit() {
				this.$api.apply_shop(this.form).then(res=>{
					console.log(res)
					this.$msg(res.msg)
					this.form={}
					setTimeout(()=>{
						uni.navigateBack({})
					},800)
				})
			}
		}
	}
</script>

<style lang="scss">
page {
	background-color: #FFFFFF;
}
.footerbtn {
		position: fixed;
		width: 90%;
		left: 50%;
		bottom: 60rpx;
		transform: translateX(-50%);
		background: #D23030;
		box-shadow: 0px 2rpx 10rpx 0px rgba(210,48,48,1);
		border-radius: 44rpx;
		font-size: 28rpx;
		color: #FFFFFF;
		text-align: center;
		line-height: 88rpx;
	}
</style>
